﻿namespace Chain.IDAL
{
    using Chain.DBUtility;
    using Chain.Model;
    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Runtime.InteropServices;
    using System.Text;
    public class Mem_share_set
    {
        public DataSet GetList(string strWhere)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select ID,Title,Content,Img,TemplateID ");
            builder.Append("from Mem_share_set");
            if (strWhere.Trim() != "")
            {
                builder.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(builder.ToString());
        }
        public int Add(Chain.Model.MemberExplanation model)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("insert into MemberExplanation(");
            builder.Append("MemberExplanationDesc,MemberExplanationTime)");
            builder.Append(" values (");
            builder.Append("@MemberExplanationDesc,@MemberExplanationTime)");
            builder.Append(";select @@IDENTITY");
            SqlParameter[] cmdParms = new SqlParameter[] { 
                new SqlParameter("@MemberExplanationDesc", SqlDbType.NVarChar, 400), new SqlParameter("@MemberExplanationTime", SqlDbType.DateTime) 
            };
            cmdParms[0].Value = model.MemberExplanationDesc;
            cmdParms[1].Value = model.MemberExplanationTime;
            object single = DbHelperSQL.GetSingle(builder.ToString(), cmdParms);
            if (single == null)
            {
                return 0;
            }
            return Convert.ToInt32(single);
        }
    }
}
